package com.syg.SpringMVC._04_SpringMVC_RandomCode;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 表单请求接受到的中文参数是乱码
 */
public class _01_SpringMVC_RandomCode implements Controller{
    @Override
    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
//        request.setCharacterEncoding("utf-8");
        String textValue = request.getParameter("textValue");
        if (null==textValue) {
            System.out.println("is null");
        }
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("Message_syg", textValue);
        modelAndView.setViewName("JspPage/_04_SpringMVC_RandomCode/_04_SpringMVC_RandomCode.jsp");
        return modelAndView;
    }
}
